<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/include/header.jsp"%>
</head>
<body  style="background-color: white;">
        <div class="clearfix">
			<form id="${simpleBeanName}Form">
				<input type="hidden" name="CSRFToken" value="<hna:csrfToken />" />
				<table class="c_table m_t10">
						<#list columnList as column>
						<tr>
							<td class="t_tit">${column.dbColumnComment}：</td>
							<td><input type="text" class="input_txt" id="${column.javaPropertyName}" name="${column.javaPropertyName}" data-validaterole="${column.javaPropertyName}" data-rule="${column.javaPropertyName}" value="" data-param='{"code" : "mmm","ml":${column.dbColumnPrecision}}' data-message='最大不能超过<!=ml!>' /></td>
						</tr>					
						</#list>
				</table>

			</form>
		</div>
		<div class="action_box m_t10 t_c">
			<input type="button" class="save_btn" id="addBtn" value="保存" />
		</div>

	<script type="text/javascript">
	// 验证
	seajs.use(["component/validate", "component/tip"], function(validate, tip) {
		var ntip = function() {
			return commonUtils.getTip(tip);
		};

		var d =  commonUtils.getValidate("${simpleBeanName}Form", "addBtn", ntip, validate);

		// 设置拼装规则: 这里加上各个验证规则
		<#list columnList as column>
		d.setValidateRule({ ${column.javaPropertyName}: ["isBlank", "checkLen"] });
		</#list>
		// 注册保存按钮事件
		d.bind("onsubmit", function() {
			var serializedForm = $("#${simpleBeanName}Form").serialize();
			commonUtils.postAjax("${ctx}/${simpleBeanName}/add.do", serializedForm, function(result){
				if (999 == result.code) {// 业务错误
					alert(result.msg);
				}
				if (200 == result.code) {
					alert("操作成功");
					parent.search();
					parent.${simpleBeanName}Dialog.close();
				}
			});
				
		});
	});
	</script>
</body>
</html>